package com.system.demo.controller.account;

import cn.dev33.satoken.annotation.SaCheckLogin;
import com.system.demo.entity.account.PasswordResetDTO;
import com.system.demo.service.account.AccountService;
import com.system.demo.tool.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

@RestController
@RequestMapping("/account")
public class AccountController {

    //此controller面向系统所有用户，可以查看 修改 个人信息
    @Autowired
    private AccountService accountService;


    //查找个人信息
    @GetMapping
    @SaCheckLogin
    public ResponseResult<?> getUserInfo(){
        return accountService.getUserInfo();
    }

    //修改头像
    @PutMapping("/avatar")
    @SaCheckLogin
    public ResponseResult<?> updateAvatar(@RequestBody MultipartFile avatar){
        return accountService.updateAvatar(avatar);
    }

    //修改密码  用户首次登录需要强制修改密码
    @PostMapping("/resetPass")
    @SaCheckLogin
    public ResponseResult<?> resetPassword(@RequestBody PasswordResetDTO passwordResetDTO){
        return accountService.resetPassword(passwordResetDTO);
    }

    //设定邮箱
    @PutMapping("/email")
    @SaCheckLogin
    public ResponseResult<?> setEmail(@RequestParam String email){
        return accountService.setEmail(email);
    }

    @GetMapping("/verifyEmail")
    public ResponseResult<?> verifyEmail(@RequestParam String token){
        return accountService.verifyEmail(token);
    }

    //查看关于自己的系统通知
    @GetMapping("/getNotifications")
    @SaCheckLogin
    public ResponseResult<?> getNotifications(@RequestParam Integer page, @RequestParam Integer size){
        return accountService.getNotifications(page, size);
    }

}
